package com.compare.service;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.config.dao.ChargeConfigDao;
import com.config.dao.EquipmentDao;
import com.config.dao.LineConfigDao;
import com.config.dao.ShiftConfigDao;
import com.config.entity.Equipment;
import com.config.entity.LineConfig;
import com.config.entity.ShiftConfig;
import com.data.dao.ChargeDayDao;
import com.data.dao.ChargeMinDao;
import com.data.dao.ChargeMonthDao;
import com.data.dao.ChargeShiftDao;
import com.data.dao.ChargeWeekDao;
import com.data.dao.StateDayDao;
import com.data.dao.StateMinDao;
import com.data.dao.StateMonthDao;
import com.data.dao.StateWeekDao;
import com.data.entity.ChargeDay;
import com.data.entity.ChargeMin;
import com.data.entity.ChargeMonth;
import com.data.entity.ChargeShift;
import com.data.entity.ChargeWeek;
import com.data.entity.StateMin;
import com.data.entity.StateWeek;
import com.line.dao.LineDao;

@Service("compareService")
public class CompareServiceImpl implements CompareService{
	@Resource(name="lineDao")
	private LineDao lineDao;
	@Resource(name="lineConfigDao")
	private LineConfigDao lineConfigDao;
	@Resource(name="equipmentDao")
	private  EquipmentDao equipmentDao;
	@Resource(name="shiftConfigDao")
	private ShiftConfigDao shiftConfigDao;
	@Resource(name = "chargeConfigDao")
	private ChargeConfigDao chargeConfigDao;
	@Resource(name="chargeMinDao")
	private ChargeMinDao chargeMinDao;
	@Resource(name="chargeShiftDao")
	private ChargeShiftDao chargeShiftDao;
	@Resource(name="chargeDayDao")
	private ChargeDayDao chargeDayDao;
	@Resource(name="chargeWeekDao")
	private ChargeWeekDao chargeWeekDao;
	@Resource(name="chargeMonthDao")
	private ChargeMonthDao chargeMonthDao;
	@Resource(name="stateMinDao")
	private StateMinDao stateMinDao;
	@Resource(name="stateDayDao")
	private StateDayDao stateDayDao;
	@Resource(name="stateWeekDao")
	private StateWeekDao stateWeekDao;
	@Resource(name="stateMonthDao")
	private StateMonthDao stateMonthDao;
	/**
	 * 整线设备对比日分析电度电费数据
	 * @param lineId
	 * @param belongTime 如2016-10-25 10:00格式
	 * @param model
	 */
	@Override
	public void getEleChargeCompareDayData(int lineId, String belongTime, Map<String, Object> model) {
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";
		List<Double> machineDuration=new ArrayList<Double>();//停机时长
		List<String> equNames=new ArrayList<String>();//设备
		List<String> stateLeg=Arrays.asList(new String[]{"满载","空载"});//满载空载率
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Integer> chargeBar=new ArrayList<Integer>();//设备电费
		List<Map<String,Object>> fullRateBar=new ArrayList<Map<String,Object>>();//设备满载率
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//		ChargeMin cmin=chargeMinDao.getChargeMinByIdAndDate(lineId, belongTime, "Y");
//		if(cmin!=null){
//			 totalElectric=cmin.getRelativeComp().intValue();
//			 totalCharge=cmin.getCharge().intValue();
//		 }
		//所有设备
		List<Equipment> equs=equipmentDao.listByLine(lineId);
		if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					//此处state应为“停机” 由于停机数据为0  暂时用“待机”  时间截取保留到分
					StateMin state=stateMinDao.getStateMinByDate(e.getId(), "待机", belongTime.substring(0, 16));
					if(state!=null){
						machineDuration.add(state.getDuration());
					}else{
						machineDuration.add(0.0);
					}
					//设备电度电费
					ChargeMin min=chargeMinDao.getChargeMinByIdAndDate(e.getId(), belongTime, "N");
					if(min!=null){
						electricityBar.add(min.getRelativeComp().intValue());
						chargeBar.add(min.getCharge().intValue());
					}else{
						electricityBar.add(0);
						chargeBar.add(0);
					}
				}
			}
			//找出最大停机时长和最小停机时长
			int maxIndex=0; int minIndex=0;
			double maxDuration=machineDuration.get(0); double minDuration=machineDuration.get(0); 
			for(int i=0;i<machineDuration.size();i++){
				if(maxDuration<machineDuration.get(i)){
					maxDuration=machineDuration.get(i);
					maxIndex=i;
				}
				if(minDuration>machineDuration.get(i)){
					minDuration=machineDuration.get(i);
					minIndex=i;
				}
			}
			bottleneckEqu=equNames.get(minIndex);
			proficiencyEqu=equNames.get(maxIndex);
		
			 // 满载率  空载率
		    for(String state:stateLeg){
				if(equs.size()!=0){
					List<Double> equRate=new ArrayList<Double>();
					for(Equipment e:equs){
						StateMin smin=stateMinDao.getStateMinByDate(e.getId(), state, belongTime.substring(0, 16));
						if(smin!=null){
							double rate=Double.parseDouble(df.format((smin.getDuration())/(1*3600)*100));
							equRate.add(rate);
						}else{
							equRate.add(0.0);
						}
					}
					Map<String, Object> stated=new HashMap<String, Object>();
					stated.put("name", state);
					stated.put("value",equRate);
					fullRateBar.add(stated);
				}
			}
		     model.put("equNames", equNames);
			 model.put("lineName", lineName);
			 model.put("belongTime", belongTime);
//			 model.put("totalElectric", totalElectric+"度");
//			 model.put("totalCharge", totalCharge+"元");
			 model.put("bottleneckEqu", bottleneckEqu);
			 model.put("proficiencyEqu", proficiencyEqu);
			 
			 model.put("electricityBar", electricityBar);
			 model.put("chargeBar", chargeBar);
			 model.put("stateLeg", stateLeg);
			 model.put("fullRateBar", fullRateBar);
	}
	/**
	 * 整线设备对比日综合分析电度电费数据
	 * @param lineId
	 * @param startDate
	 * @param endDate
	 * @param model
	 */
	@Override
	public void getEleChargeCompareCompositeData(int lineId, String startDate,String endDate, Map<String, Object> model) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";
		List<Double> machineDuration=new ArrayList<Double>();//停机时长
		List<String> equNames=new ArrayList<String>();//设备
		List<String> shiftLeg=new ArrayList<String>();//班次
		List<String> chargeLeg=new ArrayList<String>();//峰谷值电费
		List<String> stateLeg=Arrays.asList(new String[]{"满载","空载"});//满载空载率
		List<Map<String,Object>> electricityBar=new ArrayList<Map<String,Object>>();//设备电度
		List<Map<String,Object>> chargeBar=new ArrayList<Map<String,Object>>();//设备电费
		List<Map<String,Object>> fullRateBar=new ArrayList<Map<String,Object>>();//设备满载率
		try{
			  Calendar start=Calendar.getInstance();
		      Calendar end=(Calendar) start.clone();
		      start.setTime(sdf.parse(startDate));
		      end.setTime(sdf.parse(endDate));
		      int aeraDay=(int) ((end.getTimeInMillis()-start.getTimeInMillis())/(24*3600*1000L));
			 LineConfig linec=lineConfigDao.get(lineId);
			 String lineName=linec.getName()+"("+linec.getLinesNo()+")";
			
//			 ChargeDay cday=chargeDayDao.getCompAndChargeByType(lineId, startDate, endDate, "", "Y");
//			 if(cday!=null){
//				totalElectric=cday.getRelativeComp().intValue();
//				totalCharge=cday.getCharge().intValue();
//			}
			//所有设备
			List<Equipment> equs=equipmentDao.listByLine(lineId);
			if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					//此处state应为“停机” 由于停机数据为0  暂时用“待机”
					double duration=stateDayDao.getTotalWorkTime(e.getId(), startDate, endDate, "待机");
					machineDuration.add(duration);
				}
			}
			//找出最大停机时长和最小停机时长
			int maxIndex=0; int minIndex=0;
			double maxDuration=machineDuration.get(0); double minDuration=machineDuration.get(0); 
			for(int i=0;i<machineDuration.size();i++){
				if(maxDuration<machineDuration.get(i)){
					maxDuration=machineDuration.get(i);
					maxIndex=i;
				}
				if(minDuration>machineDuration.get(i)){
					minDuration=machineDuration.get(i);
					minIndex=i;
				}
			}
			bottleneckEqu=equNames.get(minIndex);
			proficiencyEqu=equNames.get(maxIndex);
			
			//班次电度
			ShiftConfig  config=shiftConfigDao.findShiftsByTime(lineId, startDate, endDate);
			if(config!=null){
				List<ShiftConfig> useShifts=shiftConfigDao.findByShiftsId(config.getId());
				if(useShifts.size()!=0){
					for(ShiftConfig s:useShifts){
						shiftLeg.add(s.getShiftName());
						if(equs.size()!=0){
							List<Integer> shiftEle=new ArrayList<Integer>();
							for(Equipment e:equs){
								ChargeShift cshift=chargeShiftDao.getShiftElectricAndChargeByAreaDate(e.getId(), s.getId(), startDate,endDate, "N");
							    if(cshift!=null){
							    	shiftEle.add(cshift.getRelativeComp().intValue());
							    }else{
							    	shiftEle.add(0);
							    }
							}
							Map<String, Object> dayEle=new HashMap<String, Object>();
					    	dayEle.put("name", s.getShiftName());
					    	dayEle.put("value", shiftEle);
					    	electricityBar.add(dayEle);
						}
					}
				}
			}
			 //峰谷值电费
			 List<ChargeDay> days=chargeDayDao.getDistricChargeName(lineId, startDate, endDate, "Y");
			 if(days.size()!=0){
				 for(ChargeDay c:days){
					 chargeLeg.add(c.getChargeName()+"电费");
						if(equs.size()!=0){
							List<Integer> typeCha=new ArrayList<Integer>();
							for(Equipment e:equs){
								ChargeDay day=chargeDayDao.getCompAndChargeByType(e.getId(), startDate,endDate, c.getChargeName(),"N");
								if(day!=null){
									typeCha.add(day.getCharge().intValue());
								}else{
									typeCha.add(0);
								}
							}
							Map<String, Object> dayCha=new HashMap<String, Object>();
							dayCha.put("name", c.getChargeName()+"电费");
							dayCha.put("value", typeCha);
							chargeBar.add(dayCha);
						}
					}
				 }else{
					 chargeLeg.add("电费");
					 if(equs.size()!=0){
							List<Integer> typeCha=new ArrayList<Integer>();
							for(int i=0;i<equs.size();i++){
								typeCha.add(0);
							}
							Map<String, Object> dayCha=new HashMap<String, Object>();
							dayCha.put("name", "电费");
							dayCha.put("value", typeCha);
							chargeBar.add(dayCha);
						}
				 }
			 // 满载率  空载率
			 for(String state:stateLeg){
					if(equs.size()!=0){
						List<Double> equRate=new ArrayList<Double>();
						for(Equipment e:equs){
							double duration=stateDayDao.getTotalWorkTime(e.getId(), startDate,endDate,state);
							double rate=Double.parseDouble(df.format(duration/(aeraDay*24*3600)*100));
							equRate.add(rate);
						}
						Map<String, Object> stated=new HashMap<String, Object>();
						stated.put("name", state);
						stated.put("value",equRate);
						fullRateBar.add(stated);
					}
				}
			     model.put("equNames", equNames);
				 model.put("lineName", lineName);
				 model.put("startDate", startDate);
				 model.put("endDate", endDate);
//				 model.put("totalElectric", totalElectric+"度");
//				 model.put("totalCharge", totalCharge+"元");
				 model.put("bottleneckEqu", bottleneckEqu);
				 model.put("proficiencyEqu", proficiencyEqu);
				 
				 model.put("shiftLeg", shiftLeg);
				 model.put("electricityBar", electricityBar);
				 model.put("chargeLeg", chargeLeg);
				 model.put("chargeBar", chargeBar);
				 model.put("stateLeg", stateLeg);
				 model.put("fullRateBar", fullRateBar);
			} catch (ParseException e) {
			e.printStackTrace();
		}
	 }
	/**
	 * 整线设备对比周分析电度电费数据
	 * @param lineId
	 * @param belongYear
	 * @param startWeek
	 * @param endWeek
	 * @param model
	 */
	@Override
	public void getEleChargeCompareWeekData(int lineId, int belongYear,int startWeek,int endWeek, Map<String, Object> model) {
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";
		List<Double> machineDuration=new ArrayList<Double>();//停机时长
		List<String> equNames=new ArrayList<String>();//设备
		List<String> chargeLeg=new ArrayList<String>();//峰谷值电费
		List<String> stateLeg=Arrays.asList(new String[]{"满载","空载"});//满载空载率
		
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Map<String,Object>> chargeBar=new ArrayList<Map<String,Object>>();//设备电费
		List<Map<String,Object>> fullRateBar=new ArrayList<Map<String,Object>>();//设备满载率
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//		ChargeWeek cweek=chargeWeekDao.getDurationByChargeNameAndDate(lineId, belongYear, startWeek,endWeek,"", "Y");
//		if(cweek!=null){
//			totalElectric=cweek.getRelativeComp().intValue();
//			totalCharge=cweek.getCharge().intValue();
//		}
		//所有设备
		List<Equipment> equs=equipmentDao.listByLine(lineId);
		if(equs.size()!=0){
			for(Equipment e:equs){
				equNames.add(e.getEquNo());
				//此处state应为“停机” 由于停机数据为0  暂时用“待机”
				StateWeek sweek=stateWeekDao.getdurationByStateAndDate(e.getId(), belongYear,startWeek, endWeek, "待机");
				if(sweek!=null){
					machineDuration.add(sweek.getDuration());
				}else{
					machineDuration.add(0.0);
				}
				//设备电度
				ChargeWeek charweek=chargeWeekDao.getDurationByChargeNameAndDate(e.getId(), belongYear, startWeek,endWeek,"", "N");
				if(charweek!=null){
					electricityBar.add(charweek.getRelativeComp().intValue());
				}else{
					electricityBar.add(0);
				}
			}
		}
		//找出最大停机时长和最小停机时长
		int maxIndex=0; int minIndex=0;
		double maxDuration=machineDuration.get(0); double minDuration=machineDuration.get(0); 
		for(int i=0;i<machineDuration.size();i++){
			if(maxDuration<machineDuration.get(i)){
				maxDuration=machineDuration.get(i);
				maxIndex=i;
			}
			if(minDuration>machineDuration.get(i)){
				minDuration=machineDuration.get(i);
				minIndex=i;
			}
		}
		bottleneckEqu=equNames.get(minIndex);
		proficiencyEqu=equNames.get(maxIndex);
		//设备电费
		List<ChargeWeek> chargeNames=chargeWeekDao.getDistinctChargeName(belongYear, startWeek, endWeek);
		if(chargeNames.size()!=0){
			for(ChargeWeek c:chargeNames){
				chargeLeg.add(c.getChargeName()+"电费");
				if(equs.size()!=0){
					List<Integer> typeCha=new ArrayList<Integer>();
					for(Equipment e:equs){
						ChargeWeek charge=chargeWeekDao.getDurationByChargeNameAndDate(e.getId(), belongYear, startWeek,endWeek, c.getChargeName(), "N");
						if(charge!=null){
							typeCha.add(charge.getCharge().intValue());
						}else{
							typeCha.add(0);
						}
					}
					Map<String, Object> weekCha=new HashMap<String, Object>();
					weekCha.put("name", c.getChargeName()+"电费");
					weekCha.put("value", typeCha);
					chargeBar.add(weekCha);
				}
	          }
			}else{
				chargeLeg.add("电费");
				if(equs.size()!=0){
					List<Integer> typeCha=new ArrayList<Integer>();
					for(int i=0;i<equs.size();i++){
							typeCha.add(0);
					}
					Map<String, Object> weekCha=new HashMap<String, Object>();
					weekCha.put("name","电费");
					weekCha.put("value", typeCha);
					chargeBar.add(weekCha);
				}
			}
		 // 满载率  空载率
		 for(String state:stateLeg){
				if(equs.size()!=0){
					List<Double> equRate=new ArrayList<Double>();
					for(Equipment e:equs){
						StateWeek sweek=stateWeekDao.getdurationByStateAndDate(e.getId(), belongYear, startWeek,endWeek, state);
						if(sweek!=null){
							double rate=Double.parseDouble(df.format(sweek.getDuration()/((endWeek-startWeek)*7*24*3600)*100));
							equRate.add(rate);
						}else{
							equRate.add(0.0);
						}
					}
					Map<String, Object> stated=new HashMap<String, Object>();
					stated.put("name", state);
					stated.put("value",equRate);
					fullRateBar.add(stated);
				}
			}
		     model.put("equNames", equNames);
			 model.put("lineName", lineName);
			 model.put("startDate", belongYear+"年第"+startWeek+"周");
			 model.put("endDate", belongYear+"年第"+endWeek+"周");
//			 model.put("totalElectric", totalElectric+"度");
//			 model.put("totalCharge", totalCharge+"元");
			 model.put("bottleneckEqu", bottleneckEqu);
			 model.put("proficiencyEqu", proficiencyEqu);
			 
			 model.put("electricityBar", electricityBar);
			 model.put("chargeLeg", chargeLeg);
			 model.put("chargeBar", chargeBar);
			 model.put("stateLeg", stateLeg);
			 model.put("fullRateBar", fullRateBar);
		}
	/**
	 * 整线设备对比月分析电度电费数据
	 * @param lineId
	 * @param belongYear
	 * @param startMonth
	 * @param endMonth
	 * @param model
	 */
	@Override
	public void getEleChargeCompareMonthData(int lineId, int belongYear, int startMonth,int endMonth,Map<String, Object> model) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";int areaDays=0;
		List<Double> machineDuration=new ArrayList<Double>();//停机时长
		List<String> equNames=new ArrayList<String>();//设备
		List<String> chargeLeg=new ArrayList<String>();//峰谷值电费
		List<String> stateLeg=Arrays.asList(new String[]{"满载","空载"});//满载空载率
		
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Map<String,Object>> chargeBar=new ArrayList<Map<String,Object>>();//设备电费
		List<Map<String,Object>> fullRateBar=new ArrayList<Map<String,Object>>();//设备满载率
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
		try {
			String startDate = sdf.format(sdf.parse(belongYear+"-"+startMonth));
			String endDate=sdf.format(sdf.parse(belongYear+"-"+endMonth));
			for(int month=startMonth;month<=endMonth;month++){
				Date belongDate=sdf.parse(belongYear+"-"+month);
				Calendar ca = Calendar.getInstance();  
				ca.setTime(belongDate);
				areaDays+=ca.getActualMaximum(Calendar.DAY_OF_MONTH);
			}
			
//			ChargeMonth cmonth=chargeMonthDao.getDurationByChargeNameAndDate(lineId, startDate,endDate, "", "Y");
//			if(cmonth!=null){
//				totalElectric=cmonth.getRelativeComp().intValue();
//				totalCharge=cmonth.getCharge().intValue();
//			}
			
			//所有设备
			List<Equipment> equs=equipmentDao.listByLine(lineId);
			if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					//此处state应为“停机” 由于停机数据为0  暂时用“待机”
					double duration=stateMonthDao.getTotalWorkTime(e.getId(),startDate,endDate, "待机");
					machineDuration.add(duration);
					//设备电度
					ChargeMonth charmonth=chargeMonthDao.getDurationByChargeNameAndDate(e.getId(), startDate,endDate, "", "N");
					if(charmonth!=null){
						electricityBar.add(charmonth.getRelativeComp().intValue());
					}else{
						electricityBar.add(0);
					}
				}
			}
			//找出最大停机时长和最小停机时长
			int maxIndex=0; int minIndex=0;
			double maxDuration=machineDuration.get(0); double minDuration=machineDuration.get(0); 
			for(int i=0;i<machineDuration.size();i++){
				if(maxDuration<machineDuration.get(i)){
					maxDuration=machineDuration.get(i);
					maxIndex=i;
				}
				if(minDuration>machineDuration.get(i)){
					minDuration=machineDuration.get(i);
					minIndex=i;
				}
			}
			bottleneckEqu=equNames.get(minIndex);
			proficiencyEqu=equNames.get(maxIndex);
			
			//设备电费
			List<ChargeMonth> chargeNames=chargeMonthDao.getDistinctChargeName(startDate, endDate);
			if(chargeNames.size()!=0){
				for(ChargeMonth c:chargeNames){
					chargeLeg.add(c.getChargeName()+"电费");
					if(equs.size()!=0){
						List<Integer> typeCha=new ArrayList<Integer>();
						for(Equipment e:equs){
							ChargeMonth charge=chargeMonthDao.getDurationByChargeNameAndDate(e.getId(), startDate,endDate, c.getChargeName(), "N");
							if(charge!=null){
								typeCha.add(charge.getCharge().intValue());
							}else{
								typeCha.add(0);
							}
						}
						Map<String, Object> weekCha=new HashMap<String, Object>();
						weekCha.put("name", c.getChargeName()+"电费");
						weekCha.put("value", typeCha);
						chargeBar.add(weekCha);
					}
		          }
				}else{
					chargeLeg.add("电费");
					if(equs.size()!=0){
						List<Integer> typeCha=new ArrayList<Integer>();
						for(int i=0;i<equs.size();i++){
								typeCha.add(0);
						}
						Map<String, Object> weekCha=new HashMap<String, Object>();
						weekCha.put("name","电费");
						weekCha.put("value", typeCha);
						chargeBar.add(weekCha);
					}
				}
			 // 满载率  空载率
			 for(String state:stateLeg){
					if(equs.size()!=0){
						List<Double> equRate=new ArrayList<Double>();
						for(Equipment e:equs){
							double duration=stateMonthDao.getTotalWorkTime(e.getId(), startDate,endDate,state);
							double rate=Double.parseDouble(df.format(duration/(areaDays*24*3600)*100));
							equRate.add(rate);
						}
						Map<String, Object> stated=new HashMap<String, Object>();
						stated.put("name", state);
						stated.put("value",equRate);
						fullRateBar.add(stated);
					}
				}
			 model.put("equNames", equNames);
			 model.put("lineName", lineName);
			 model.put("startDate", startDate);
			 model.put("endDate", endDate);
//			 model.put("totalElectric", totalElectric+"度");
//			 model.put("totalCharge", totalCharge+"元");
			 model.put("bottleneckEqu", bottleneckEqu);
			 model.put("proficiencyEqu", proficiencyEqu);
			 
			 model.put("electricityBar", electricityBar);
			 model.put("chargeLeg", chargeLeg);
			 model.put("chargeBar", chargeBar);
			 model.put("stateLeg", stateLeg);
			 model.put("fullRateBar", fullRateBar);
			 
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	/**
	 * 整线设备开动率日对比分析
	 * @param lineId
	 * @param belongTime 如2016-10-25 10:00格式
	 * @param model
	 */
	@Override
	public void getStartRateCompareDayData(int lineId, String belongTime, Map<String, Object> model) {
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";
		double bottleneckRate=0.0;double proficiencyRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Double> startRateLine=new ArrayList<Double>();//设备开动率
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//		ChargeMin cmin=chargeMinDao.getChargeMinByIdAndDate(lineId, belongTime, "Y");
//		 if(cmin!=null){
//			 totalElectric=cmin.getRelativeComp().intValue();
//			 totalCharge=cmin.getCharge().intValue();
//		 }
		 //所有设备
		 List<Equipment> equs=equipmentDao.listByLine(lineId);
		 if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					//此处state应为“停机” 由于停机数据为0  暂时用“待机”  时间截取保留到分
					StateMin state=stateMinDao.getStateMinByDate(e.getId(), "待机", belongTime.substring(0, 16));
					if(state!=null){
						startRateLine.add(Double.parseDouble(df.format((state.getDuration())/3600*100)));
					}else{
						startRateLine.add(0.0);
					}
					//设备电度
					ChargeMin min=chargeMinDao.getChargeMinByIdAndDate(e.getId(), belongTime, "N");
					if(min!=null){
						electricityBar.add(min.getRelativeComp().intValue());
					}else{
						electricityBar.add(0);
					}
				}
			}
			//找出最大停机时长和最小停机时长
			int maxIndex=0; int minIndex=0;
			double maxStartRate=startRateLine.get(0); double minStartRate=startRateLine.get(0); 
			for(int i=0;i<startRateLine.size();i++){
				if(maxStartRate<startRateLine.get(i)){
					maxStartRate=startRateLine.get(i);
					maxIndex=i;
				}
				if(minStartRate>startRateLine.get(i)){
					minStartRate=startRateLine.get(i);
					minIndex=i;
				}
			}
			bottleneckEqu=equNames.get(minIndex);
			proficiencyEqu=equNames.get(maxIndex);
			
			bottleneckRate=maxStartRate;
			proficiencyRate=minStartRate;
			
			model.put("belongTime", belongTime);
			model.put("lineName", lineName);
			model.put("equNames", equNames);
//			model.put("totalElectric", totalElectric+"度");
//			model.put("totalCharge", totalCharge+"元");
			
			model.put("bottleneckEqu", bottleneckEqu);
			model.put("proficiencyEqu", proficiencyEqu);
			model.put("bottleneckRate", bottleneckRate);
			model.put("proficiencyRate", proficiencyRate);
			
			model.put("electricityBar", electricityBar);
			model.put("startRateLine", startRateLine);
			
	}
	/**
	 * 整线设备开动率日综合对比分析
	 * @param lineId
	 * @param startDate
	 * @param endDate
	 * @param model
	 */
	@Override
	public void getStartRateCompareCompositeData(int lineId, String startDate,String endDate, Map<String, Object> model) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";int aeraDay=0;
		double bottleneckRate=0.0;double proficiencyRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Double> startRateLine=new ArrayList<Double>();//设备开动率
		try{
			  Calendar start=Calendar.getInstance();
		      Calendar end=(Calendar) start.clone();
		      start.setTime(sdf.parse(startDate));
		      end.setTime(sdf.parse(endDate));
		      aeraDay=(int) ((end.getTimeInMillis()-start.getTimeInMillis())/(24*3600*1000L));
			  LineConfig linec=lineConfigDao.get(lineId);
			  String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//			  ChargeDay cday=chargeDayDao.getCompAndChargeByType(lineId, startDate, endDate, "", "Y");
//			  if(cday!=null){
//					totalElectric=cday.getRelativeComp().intValue();
//					totalCharge=cday.getCharge().intValue();
//				}
				//所有设备
				List<Equipment> equs=equipmentDao.listByLine(lineId);
				if(equs.size()!=0){
					for(Equipment e:equs){
						equNames.add(e.getEquNo());
						//此处state应为“停机” 由于停机数据为0  暂时用“待机”
						double duration=stateDayDao.getTotalWorkTime(e.getId(), startDate,endDate,"待机");
						startRateLine.add(Double.parseDouble(df.format(duration/(aeraDay*24*3600)*100)));
						//设备电度
					   ChargeDay day=chargeDayDao.getCompAndChargeByType(e.getId(), startDate,endDate, "","N");
					   if(day!=null){
						   electricityBar.add(day.getRelativeComp().intValue());
					   }else{
						   electricityBar.add(0);
					   }
					}
				}
				//找出最大停机时长和最小停机时长
				int maxIndex=0; int minIndex=0;
				double maxStartRate=startRateLine.get(0); double minStartRate=startRateLine.get(0); 
				for(int i=0;i<startRateLine.size();i++){
					if(maxStartRate<startRateLine.get(i)){
						maxStartRate=startRateLine.get(i);
						maxIndex=i;
					}
					if(minStartRate>startRateLine.get(i)){
						minStartRate=startRateLine.get(i);
						minIndex=i;
					}
				}
				bottleneckEqu=equNames.get(minIndex);
				proficiencyEqu=equNames.get(maxIndex);
				
				bottleneckRate=maxStartRate;
				proficiencyRate=minStartRate;
				
				model.put("startDate", startDate);
				model.put("endDate", endDate);
				model.put("lineName", lineName);
				model.put("equNames", equNames);
//				model.put("totalElectric", totalElectric+"度");
//				model.put("totalCharge", totalCharge+"元");
				
				model.put("bottleneckEqu", bottleneckEqu);
				model.put("proficiencyEqu", proficiencyEqu);
				model.put("bottleneckRate", bottleneckRate);
				model.put("proficiencyRate", proficiencyRate);
				
				model.put("electricityBar", electricityBar);
				model.put("startRateLine", startRateLine);
				} catch (ParseException e) {
					e.printStackTrace();
				}
	}
	/**
	 * 整线设备开动率周对比分析
	 * @param lineId
	 * @param belongYear
	 * @param week
	 * @param model
	 */
	@Override
	public void getStartRateCompareWeekData(int lineId, int belongYear, int startWeek,int endWeek, Map<String, Object> model) {
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";
		double bottleneckRate=0.0;double proficiencyRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Double> startRateLine=new ArrayList<Double>();//设备开动率
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
		
//		ChargeWeek cweek=chargeWeekDao.getDurationByChargeNameAndDate(lineId, belongYear, startWeek,endWeek,"", "Y");
//		if(cweek!=null){
//			totalElectric=cweek.getRelativeComp().intValue();
//			totalCharge=cweek.getCharge().intValue();
//		}
		//所有设备
		List<Equipment> equs=equipmentDao.listByLine(lineId);
		if(equs.size()!=0){
			for(Equipment e:equs){
				equNames.add(e.getEquNo());
				//此处state应为“停机” 由于停机数据为0  暂时用“待机”
				StateWeek state=stateWeekDao.getdurationByStateAndDate(e.getId(), belongYear, startWeek,endWeek, "待机");
				if(state!=null){
					startRateLine.add(Double.parseDouble(df.format((state.getDuration())/((endWeek-startWeek)*7*24*3600)*100)));
				}
				//设备电度
			   ChargeWeek weeks=chargeWeekDao.getDurationByChargeNameAndDate(e.getId(), belongYear, startWeek,endWeek,"", "N");
			   if(weeks!=null){
				   electricityBar.add(weeks.getRelativeComp().intValue());
			   }else{
				   electricityBar.add(0);
			   }
			}
		}
		//找出最大停机时长和最小停机时长
		int maxIndex=0; int minIndex=0;
		double maxStartRate=startRateLine.get(0); double minStartRate=startRateLine.get(0); 
		for(int i=0;i<startRateLine.size();i++){
			if(maxStartRate<startRateLine.get(i)){
				maxStartRate=startRateLine.get(i);
				maxIndex=i;
			}
			if(minStartRate>startRateLine.get(i)){
				minStartRate=startRateLine.get(i);
				minIndex=i;
			}
		}
		bottleneckEqu=equNames.get(minIndex);
		proficiencyEqu=equNames.get(maxIndex);
		
		bottleneckRate=maxStartRate;
		proficiencyRate=minStartRate;
		
		model.put("startDate", belongYear+"年第"+startWeek+"周");
		model.put("endDate", belongYear+"年第"+endWeek+"周");
		model.put("lineName", lineName);
		model.put("equNames", equNames);
//		model.put("totalElectric", totalElectric+"度");
//		model.put("totalCharge", totalCharge+"元");
		
		model.put("bottleneckEqu", bottleneckEqu);
		model.put("proficiencyEqu", proficiencyEqu);
		model.put("bottleneckRate", bottleneckRate);
		model.put("proficiencyRate", proficiencyRate);
		
		model.put("electricityBar", electricityBar);
		model.put("startRateLine", startRateLine);
	}
	/**
	 * 整线设备开动率月对比分析
	 * @param lineId
	 * @param belongYear
	 * @param startMonth
	 * @param endMonth
	 * @param model
	 */
	@Override
	public void getStartRateCompareMonthData(int lineId, int belongYear, int startMonth,int endMonth, Map<String, Object> model) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String bottleneckEqu="";String proficiencyEqu="";int areaDays=0;
		double bottleneckRate=0.0;double proficiencyRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> electricityBar=new ArrayList<Integer>();//设备电度
		List<Double> startRateLine=new ArrayList<Double>();//设备开动率
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
		try {
			String startDate = sdf.format(sdf.parse(belongYear+"-"+startMonth));
			String endDate=sdf.format(sdf.parse(belongYear+"-"+endMonth));
			for(int month=startMonth;month<=endMonth;month++){
				Date belongDate=sdf.parse(belongYear+"-"+month);
				Calendar ca = Calendar.getInstance();  
				ca.setTime(belongDate);
				areaDays+=ca.getActualMaximum(Calendar.DAY_OF_MONTH);
			}
			
//			ChargeMonth cmonth=chargeMonthDao.getDurationByChargeNameAndDate(lineId, startDate,endDate, "", "Y");
//			if(cmonth!=null){
//				totalElectric=cmonth.getRelativeComp().intValue();
//				totalCharge=cmonth.getCharge().intValue();
//			}
			//所有设备
			List<Equipment> equs=equipmentDao.listByLine(lineId);
			if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					//此处state应为“停机” 由于停机数据为0  暂时用“待机”
					double duration=stateMonthDao.getTotalWorkTime(e.getId(), startDate,endDate,"待机");
					startRateLine.add(Double.parseDouble(df.format((duration)/(areaDays*24*3600)*100)));
	
					//设备电度
					ChargeMonth charmonth=chargeMonthDao.getDurationByChargeNameAndDate(e.getId(), startDate,endDate, "", "N");
					if(charmonth!=null){
						electricityBar.add(charmonth.getRelativeComp().intValue());
					}else{
						electricityBar.add(0);
					}
				}
			}
			//找出最大停机时长和最小停机时长
			int maxIndex=0; int minIndex=0;
			double maxStartRate=startRateLine.get(0); double minStartRate=startRateLine.get(0); 
			for(int i=0;i<startRateLine.size();i++){
				if(maxStartRate<startRateLine.get(i)){
					maxStartRate=startRateLine.get(i);
					maxIndex=i;
				}
				if(minStartRate>startRateLine.get(i)){
					minStartRate=startRateLine.get(i);
					minIndex=i;
				}
			}
			bottleneckEqu=equNames.get(minIndex);
			proficiencyEqu=equNames.get(maxIndex);
			
			bottleneckRate=maxStartRate;
			proficiencyRate=minStartRate;
			
			model.put("startDate", startDate);
			model.put("endDate", endDate);
			model.put("lineName", lineName);
			model.put("equNames", equNames);
//			model.put("totalElectric", totalElectric+"度");
//			model.put("totalCharge", totalCharge+"元");
			
			model.put("bottleneckEqu", bottleneckEqu);
			model.put("proficiencyEqu", proficiencyEqu);
			model.put("bottleneckRate", bottleneckRate);
			model.put("proficiencyRate", proficiencyRate);
			
			model.put("electricityBar", electricityBar);
			model.put("startRateLine", startRateLine);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	/**
	 * 整线设备超载日对比分析
	 * @param lineId
	 * @param belongTime 如2016-10-25 10:00:00格式
	 * @param model
	 */
	@Override
	public void getOverLoadComparaDayData(int lineId, String belongTime, Map<String, Object> model) {
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String overLoadEqu="";
		int overLoadTimes=0;double overLoadRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> overTimes=new ArrayList<Integer>();//设备超载时长
		List<Double> overRates=new ArrayList<Double>();//设备超载比例
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//		ChargeMin cmin=chargeMinDao.getChargeMinByIdAndDate(lineId, belongTime, "Y");
//		 if(cmin!=null){
//			 totalElectric=cmin.getRelativeComp().intValue();
//			 totalCharge=cmin.getCharge().intValue();
//		 }
		 //所有设备
		 List<Equipment> equs=equipmentDao.listByLine(lineId);
		 if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					StateMin state=stateMinDao.getStateMinByDate(e.getId(), "超载", belongTime.substring(0, 16));
					if(state!=null){
						overTimes.add(state.getDuration().intValue());
						overRates.add(Double.parseDouble(df.format(state.getDuration()/3600*100)));
					}else{
						overTimes.add(0);
						overRates.add(0.0);
					}
				}
			}
			//找出最大超载时长
			int maxIndex=0; 
			double maxStartRate=overRates.get(0); 
			for(int i=0;i<overRates.size();i++){
				if(maxStartRate<overRates.get(i)){
					maxStartRate=overRates.get(i);
					maxIndex=i;
				}
			}
			overLoadRate=maxStartRate;
			overLoadTimes=overTimes.get(maxIndex);
			overLoadEqu=equNames.get(maxIndex);
			
			model.put("belongTime", belongTime);
			model.put("lineName", lineName);
			model.put("equNames", equNames);
//			model.put("totalElectric", totalElectric+"度");
//			model.put("totalCharge", totalCharge+"元");
			
			model.put("overLoadRate", overLoadRate+"%");
			model.put("overLoadTimes", overLoadTimes+"秒");
			model.put("overLoadEqu", overLoadEqu);
			model.put("overTimes", overTimes);
			model.put("overRates", overRates);
	}
	/**
	 * 整线设备超载日综合对比分析
	 * @param lineId
	 * @param startDate
	 * @param endDate
	 * @param model
	 */
	@Override
	public void getOverLoadCompareCompositeData(int lineId,String startDate,String endDate,Map<String, Object> model) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String overLoadEqu=""; int aeraDay=0;
		int overLoadTimes=0;double overLoadRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> overTimes=new ArrayList<Integer>();//设备超载时长
		List<Double> overRates=new ArrayList<Double>();//设备超载比例
		try{
			  Calendar start=Calendar.getInstance();
		      Calendar end=(Calendar) start.clone();
		      start.setTime(sdf.parse(startDate));
		      end.setTime(sdf.parse(endDate));
		      aeraDay=(int) ((end.getTimeInMillis()-start.getTimeInMillis())/(24*3600*1000L));
		      LineConfig linec=lineConfigDao.get(lineId);
		      String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//			  ChargeDay cday=chargeDayDao.getCompAndChargeByType(lineId, startDate, endDate, "", "Y");
//			  if(cday!=null){
//				totalElectric=cday.getRelativeComp().intValue();
//				totalCharge=cday.getCharge().intValue();
//			   }
			  //所有设备
			 List<Equipment> equs=equipmentDao.listByLine(lineId);
				if(equs.size()!=0){
					for(Equipment e:equs){
						equNames.add(e.getEquNo());
						double duration=stateDayDao.getTotalWorkTime(e.getId(), startDate,endDate,"超载");
						overTimes.add((int)duration/60);
						overRates.add(Double.parseDouble(df.format(duration/(aeraDay*24*3600)*100)));
					}
				}
			//找出最大超载时长
			int maxIndex=0; 
			double maxStartRate=overRates.get(0); 
			for(int i=0;i<overRates.size();i++){
				if(maxStartRate<overRates.get(i)){
					maxStartRate=overRates.get(i);
					maxIndex=i;
				}
			}
			overLoadRate=maxStartRate;
			overLoadTimes=overTimes.get(maxIndex);
			overLoadEqu=equNames.get(maxIndex);
			
			model.put("startDate", startDate);
			model.put("endDate", endDate);
			model.put("lineName", lineName);
			model.put("equNames", equNames);
//			model.put("totalElectric", totalElectric+"度");
//			model.put("totalCharge", totalCharge+"元");
			
			model.put("overLoadRate", overLoadRate+"%");
			model.put("overLoadTimes", overLoadTimes+"分钟");
			model.put("overLoadEqu", overLoadEqu);
			model.put("overTimes", overTimes);
			model.put("overRates", overRates);
		
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	/**
	 * 整线设备超载周对比分析
	 * @param lineId
	 * @param belongYear
	 * @param startWeek
	 * @param endWeek
	 * @param model
	 */
	@Override
	public void getOverLoadComparaWeekData(int lineId,int belongYear,int startWeek,int endWeek,Map<String, Object> model) {
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String overLoadEqu="";
		int overLoadTimes=0;double overLoadRate=0.0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Integer> overTimes=new ArrayList<Integer>();//设备超载时长
		List<Double> overRates=new ArrayList<Double>();//设备超载比例
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
//		ChargeWeek cweek=chargeWeekDao.getDurationByChargeNameAndDate(lineId, belongYear, startWeek,endWeek, "","Y");
//		if(cweek!=null){
//			totalElectric=cweek.getRelativeComp().intValue();
//			totalCharge=cweek.getCharge().intValue();
//		}
		//所有设备
		List<Equipment> equs=equipmentDao.listByLine(lineId);
		if(equs.size()!=0){
			for(Equipment e:equs){
				equNames.add(e.getEquNo());
				StateWeek state=stateWeekDao.getdurationByStateAndDate(e.getId(), belongYear, startWeek,endWeek, "超载");
				if(state!=null){
					overTimes.add((state.getDuration().intValue())/60);
					overRates.add(Double.parseDouble(df.format(state.getDuration()/((endWeek-startWeek)*7*24*3600)*100)));
				}else{
					overTimes.add(0);
					overRates.add(0.0);
				}
			}
		}
		//找出最大超载时长
		int maxIndex=0; 
		double maxStartRate=overRates.get(0); 
		for(int i=0;i<overRates.size();i++){
			if(maxStartRate<overRates.get(i)){
				maxStartRate=overRates.get(i);
				maxIndex=i;
			}
		}
		overLoadRate=maxStartRate;
		overLoadTimes=overTimes.get(maxIndex);
		overLoadEqu=equNames.get(maxIndex);
		
		model.put("startDate",belongYear+"年第"+startWeek+"周");
		model.put("endDate",belongYear+"年第"+endWeek+"周");
		model.put("lineName", lineName);
		model.put("equNames", equNames);
//		model.put("totalElectric", totalElectric+"度");
//		model.put("totalCharge", totalCharge+"元");
		
		model.put("overLoadRate", overLoadRate+"%");
		model.put("overLoadTimes", overLoadTimes+"分钟");
		model.put("overLoadEqu", overLoadEqu);
		model.put("overTimes", overTimes);
		model.put("overRates", overRates);
	}
	/**
	 * 整线设备超载月对比分析
	 * @param lineId
	 * @param belongYear
	 * @param startMonth
	 * @param endMonth
	 * @param model
	 */
	@Override
	public void getOverLoadCompareMonthData(int lineId,int belongYear,int startMonth,int endMonth,Map<String,Object>model) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		DecimalFormat  df=new DecimalFormat ("0.0");
//		int totalElectric=0;int totalCharge=0;
		String overLoadEqu="";
		double overLoadTimes=0.0;double overLoadRate=0.0;int areaDays=0;
		List<String> equNames=new ArrayList<String>();//设备
		List<Double> overTimes=new ArrayList<Double>();//设备超载时长
		List<Double> overRates=new ArrayList<Double>();//设备超载比例
		
		LineConfig linec=lineConfigDao.get(lineId);
		String lineName=linec.getName()+"("+linec.getLinesNo()+")";
		try {
			String startDate = sdf.format(sdf.parse(belongYear+"-"+startMonth));
			String endDate=sdf.format(sdf.parse(belongYear+"-"+endMonth));
			for(int month=startMonth;month<=endMonth;month++){
				Date belongDate=sdf.parse(belongYear+"-"+month);
				Calendar ca = Calendar.getInstance();  
				ca.setTime(belongDate);
				areaDays+=ca.getActualMaximum(Calendar.DAY_OF_MONTH);
			}
//			ChargeMonth cmonth=chargeMonthDao.getDurationByChargeNameAndDate(lineId, startDate,endDate, "", "Y");
//			if(cmonth!=null){
//				totalElectric=cmonth.getRelativeComp().intValue();
//				totalCharge=cmonth.getCharge().intValue();
//			}
			//所有设备
			List<Equipment> equs=equipmentDao.listByLine(lineId);
			if(equs.size()!=0){
				for(Equipment e:equs){
					equNames.add(e.getEquNo());
					double duration=stateMonthDao.getTotalWorkTime(e.getId(), startDate,endDate,"超载");
					overTimes.add(Double.parseDouble(df.format(duration/3600)));
					overRates.add(Double.parseDouble(df.format(duration/(areaDays*24*3600)*100)));
			
				}
			}
			//找出最大超载时长
			int maxIndex=0; 
			double maxStartRate=overRates.get(0); 
			for(int i=0;i<overRates.size();i++){
				if(maxStartRate<overRates.get(i)){
					maxStartRate=overRates.get(i);
					maxIndex=i;
				}
			}
			overLoadRate=maxStartRate;
			overLoadTimes=overTimes.get(maxIndex);
			overLoadEqu=equNames.get(maxIndex);
			
			model.put("startDate",startDate);
			model.put("endDate",endDate);
			model.put("lineName", lineName);
			model.put("equNames", equNames);
//			model.put("totalElectric", totalElectric+"度");
//			model.put("totalCharge", totalCharge+"元");
			
			model.put("overLoadRate", overLoadRate+"%");
			model.put("overLoadTimes", overLoadTimes+"小时");
			model.put("overLoadEqu", overLoadEqu);
			model.put("overTimes", overTimes);
			model.put("overRates", overRates);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}
